<?php
session_start();
$loginId=$_SESSION['loginid'];
$name=$_SESSION['name'];
$userType=$_SESSION['user_type'];
include_once('connection/connection.php');
$id=$_REQUEST['var'];
$frm=$_REQUEST['loc'];
$sql_status="select * from tbl_dtls_q2_hp_status where id=$id order by id";
$query_status=mysql_query($sql_status);
$row_status=mysql_fetch_array($query_status)
?>


<script language=javascript>
function display(val)
{
	
		if(val == "NOT FUNCTIONAL")
		{
		
			document.getElementById('showMydiv').style.display = "none";
			document.getElementById('hideMydiv').style.display = "block";
			/*
			document.getElementById('opration_status').disabled=true;	
			document.getElementById('quality_status').disabled=true;	
			document.getElementById('yield').disabled=true;
			document.getElementById('seasonal_flunctuation').disabled=true;
			document.getElementById('fluctuation_min').disabled=true;
			document.getElementById('fluctuation_max').disabled=true;
			*/
			
		}else{
		
		document.getElementById('showMydiv').style.display = "block";
		document.getElementById('hideMydiv').style.display = "none";
		/*
		var chks = document.getElementsByName('repairable_status');
			var hasChecked = false;
			for(var j=0; j<chks.length; j++)
			{
				if(chks[j].checked)
				{
					chks[j].checked=false;
				}
			}
			document.getElementById('remarks').value="";
			//document.getElementById('nonFuncDiv').style.display = "none";
			document.getElementById('opration_status').disabled=false;	
			document.getElementById('quality_status').disabled=false;	
			document.getElementById('yield').disabled=false;
			document.getElementById('seasonal_flunctuation').disabled=false;
			document.getElementById('fluctuation_min').disabled=false;
			document.getElementById('fluctuation_max').disabled=false;
			*/
		}
}	


////////////
/*
function onload_NF()
{
	//for(i=1; i<=total; i++)
	//{ 
		//var countloc=document.getElementById('loccount').value;
		//for(var i=1;i<countloc;i++)
		//{
		var arr=document.getElementsByName('function_status');
		//alert(arr[0].value);
		if(arr[1].checked)
		{
			document.getElementById('hideMydiv').style.display = "block";
			document.getElementById('showMydiv').style.display = "none";
			var chks=document.getElementsByName('opration_status');	
			for(var j=0; j<chks.length; j++)
			{
				if(chks[j].checked)
				{
					chks[j].checked=false;
				}
			}
			//document.getElementById('quality_status'+i).disabled=true;	
			var chks1=document.getElementsByName('quality_status');	
			for(var k=0; k<chks1.length; k++)
			{
				if(chks1[k].checked)
				{
					chks1[k].checked=false;
				}
			}
			//document.getElementById('yield'+i).disabled=true;
			var chks2=document.getElementsByName('yield');	
			for(var l=0; l<chks2.length; l++)
			{
				if(chks2[l].checked)
				{
					chks2[l].checked=false;
				}
			}
			//document.getElementById('seasonal_flunctuation'+i).disabled=true;
			var chks3=document.getElementsByName('seasonal_flunctuation');	
			for(var m=0; m<chks3.length; m++)
			{
				if(chks3[m].checked)
				{
					chks3[m].checked=false;
				}
			}
			document.getElementById('water_table_fluctuation_min').disabled=true;
			document.getElementById('water_table_fluctuation_max').disabled=true;
		}	
		else
		{
			document.getElementById('hideMydiv').style.display = "none";
			var chks = document.getElementsByName('repairable_status');
			//var hasChecked = false;
			for(var j=0; j<chks.length; j++)
			{
				if(chks[j].checked)
				{
					chks[j].checked=false;
				}
			}
			document.getElementById('remarks').value="";
			document.getElementById('showMydiv').style.display = "block";
			document.getElementById('opration_status').disabled=false;	
			document.getElementById('quality_status').disabled=false;	
			document.getElementById('yield').disabled=false;
			document.getElementById('seasonal_flunctuation').disabled=false;
			document.getElementById('water_table_fluctuation_min').disabled=false;
			document.getElementById('water_table_fluctuation_max').disabled=false;
		}
	}
//}

*/
///////////////
</script>
<body onLoad="onload_NF();">
<script language="javascript" type="text/javascript" src="js/ajaxFunction_q2_new.js"></script>
<div class="section_format">	
<form action="update_q2_hp.php" method="post" name="sampleform" id="sampleform" onSubmit="return sec4_val();">
  <table border="1">
  
    <tr>
      <td colspan="2"> <strong>&nbsp;Water Source Details</strong></td>
      </tr>
    <tr>
      <td width="400"><strong>&nbsp;Habitation Name
          <input type="hidden" name="frmId" id="frmId" value="<?php echo $frm;?>" />
	      <input type="hidden" name="Id" id="Id" value="<?php echo $id;?>" />
	  <input type="hidden" name="loginId" id="loginId" value="<?php echo $loginId;?>" />
	  <input type="hidden" name="name" id="name" value="<?php echo $name;?>" />
	  <input type="hidden" name="userType" id="userType" value="<?php echo $userType;?>" />
      </strong></td>
      <?php
	  $result=mysql_query("SELECT DISTINCT habit_code,habit_name from tbl_dtls_q2_habit where q2_id='$frm' order by id");	
			?>
	  <td width="400">&nbsp;
	  <select name="habitation_name" id="habitation_name">
	  <option value="0">Select Habitation</option>
	  <?php 
	  while(list($id,$name)=mysql_fetch_array($result))
		 	{ 
				if($row_status['habitation_name']==$name)
				{      
             	 	echo "<option value=\"$id,$name\" selected>$name</option>";
				}
				else
				{
					echo "<option value=\"$id,$name\">$name</option>";
				}
         	}
			?>	 
	  </select>	  </td>
      </tr>
    <tr>
      <td><strong>&nbsp;Type of Habitation</strong></td>
      <td>&nbsp;
	  <select name="type_mh_oh" id="type_mh_oh">
	  <option value="MH" <?php echo ($row_status['type_mh_oh']=="MH")?"selected":'';?>>MH</option>
	  <option value="OH" <?php echo ($row_status['type_mh_oh']=="OH")?"selected":'';?>>OH</option>
	  </select>	  </td>
      </tr>
	  <tr>
      <td><strong>&nbsp;HP/SP</strong></td>
      <td>&nbsp;
	  <select name="hp_sp" id="hp_sp">
	  <option value="HP"  <?php echo ($row_status['hp_sp']=="HP")?"selected":'';?>>HP</option>
	  <option value="SP" <?php echo ($row_status['hp_sp']=="SP")?"selected":'';?>>SP</option>
	  </select>	  </td>
      </tr>
	  <tr>
      <td width="400"><strong>&nbsp;Location </strong></td>
      <td width="400">&nbsp;<input type="text" name="location" id="location"  value="<?php echo $row_status['location'];?>" /></td>
      </tr>
    <tr>
      <td><strong>&nbsp;Latitude </strong></td>
      <td>&nbsp;<input type="text" name="latitude" id="latitude" value="<?php echo $row_status['latitude'];?>" onBlur="float1(this,67,80);"/></td>
      </tr>
	  <tr>
      <td width="400"><strong>&nbsp;Longitude </strong></td>
      <td width="400">&nbsp;<input type="text" name="longitude" id="longitude" value="<?php echo $row_status['longitude'];?>" onBlur="float1(this,20,32);" /></td>
      </tr>
    <tr>
      <td><strong>&nbsp;Functional Status</strong></td>
      <td>&nbsp;<input type="radio" name="function_status" id="function_status" onClick="display(this.value)" value="FUNCTIONAL"<?php echo($row_status['functional_status']=='FUNCTIONAL')?'checked':'';?>/>Functional
	  		<input type="radio" name="function_status" id="function_status"  onClick="display(this.value);" value="NOT FUNCTIONAL"<?php echo($row_status['functional_status']=='NOT FUNCTIONAL')?'checked':'';?>/>Not Functional</td>
      </tr>
	  <?php
	  if($row_status['functional_status']=="NOT FUNCTIONAL"){
	  echo "<script type='text/javascript' >";
	  echo "display('NOT FUNCTIONAL');";
	  echo "</script>";
	  }
	  ?>
    <tr>
      <td colspan="2">
	  <div id="showMydiv">
	  <table border="1">
  <tr>
      <td width="394"><strong>&nbsp;Operational Status</strong></td>
      <td width="395">&nbsp;
        <input type="radio" name="opration_status" id="opration_status" value="In Use"  checked="checked"/>In Use
	  <input type="radio" name="opration_status" id="opration_status" value="Out of Use"<?php echo($row_status['operational_status']=='Out of Use')?'checked':'';?>>Out Use    </td>
  </tr>
	   <tr>
      <td><strong>&nbsp;Quality Status</strong></td>
      <td>&nbsp;<input type="radio" name="quality_status" id="quality_status" value="Potable" checked="checked" />Portable
	  <input type="radio" name="quality_status" id="quality_status" value="Not Potable"<?php echo($row_status['quality_status']=='Not Potable')?'checked':'';?>>Non Portable	  </td>
      </tr>
	   <tr>
      <td><strong>&nbsp;Yeild</strong></td>
      <td>&nbsp;<input type="radio" name="yield" id="yield" value="Good" checked="checked"/>Good
	  <input type="radio" name="yield" id="yield" value="Satisfactory"<?php echo($row_status['yield']=='Satisfactory')?'checked':'';?>>Satisfactory
	   <input type="radio" name="yield" id="yield" value="Poor"<?php echo($row_status['yield']=='Poor')?'checked':'';?>>Poor		</td>
      </tr>
	   <tr>
      <td><strong>&nbsp;Seasonal Fluctuation in Yeild</strong></td>
      <td>&nbsp;<input type="radio" name="seasonal_flunctuation" id="seasonal_flunctuation" value="No Change" checked="checked"/>No Change
	  <input type="radio" name="seasonal_flunctuation" id="seasonal_flunctuation" value="Slight Change"<?php echo($row_status['seasonal_fluctuation']=='Slight Change')?'checked':'';?>>Slight Change
	  <input type="radio" name="seasonal_flunctuation" id="seasonal_flunctuation" value="Drastic Change"<?php echo($row_status['seasonal_fluctuation']=='Drastic Change')?'checked':'';?>>Drastic Change	  </td>
      </tr>
	  <tr>
      <td><strong>&nbsp;Water Table Fluctuations (m) Min</strong></td>
      <td>&nbsp;<input type="text" name="water_table_fluctuation_min" id="fluctuation_min" value="<?php echo (int)$row_status['water_table_min'];?>" /></td>
      </tr>
	  <tr>
      <td><strong>&nbsp;Water Table Fluctuations (m) Max</strong></td>
      <td>&nbsp;<input type="text" name="water_table_fluctuation_max" id="fluctuation_max"  value="<?php echo (int)$row_status['water_table_max'];?>"/></td>
      </tr>
	  <tr>
      <td colspan="2"><strong>&nbsp;Water Quality Parameter</strong></td>
      </tr>
	  <tr>
      <td><strong>&nbsp;pH</strong></td>
      <td>&nbsp;<input type="text" name="para_ph" id="para_ph" value="<?php echo $row_status['para_ph']; ?>"   onBlur="check1(this,6,10);" /></td>
      </tr>
	  <tr>
      <td><strong>&nbsp;TDS (mg/l)</strong></td>
      <td>&nbsp;<input type="text" name="para_tds" id="para_tds"  value="<?php echo $row_status['para_tds']; ?>" onBlur="check(this,100,40000);" /></td>
      </tr>
	  <tr>
      <td><strong>&nbsp;CL (mg/l)</strong></td>
      <td>&nbsp;<input type="text" name="para_cl" id="para_cl" value="<?php echo $row_status['para_cl']; ?>" onBlur="check(this,50,15000);"  /></td>
      </tr>
	  <tr>
      <td><strong>&nbsp;F (mg/l)</strong></td>
      <td>&nbsp;<input type="text" name="para_f" id="para_f" value="<?php echo $row_status['para_f']; ?>" onBlur="check1(this,0,18);"  /></td>
      </tr>
	  <tr>
      <td><strong>&nbsp;NO3 (mg/l)</strong></td>
      <td>&nbsp;<input type="text" name="para_no3" id="para_no3" value="<?php echo $row_status['para_no3']; ?>" onBlur="check(this,0,2500);"   /></td>
      </tr>
	  <tr>
	    <td><strong>&nbsp;Date of Sampling/Testing</strong></td>
	    <td>&nbsp;<input type="text" name="firstinput" id="firstinput" value="<?php echo $row_status['para_testing_date'];?>" readonly />&nbsp;<a href="javascript:showCal('Calendar1')"><img src="images/caldr.jpg" /></a></td>
	    </tr>
	  <tr>
      <td colspan="2">&nbsp;</td>
      </tr>
	  </table>
	  </div>	  </td>
      </tr>
	  <tr>
      <td colspan="2">
	  <div id="hideMydiv" style="display:none">
	  <table border="1">
	  <tr>
      <td width="394">&nbsp;Non Functional Status</td>
      <td width="395">&nbsp; 
         <input type="radio" name="Repairable" id="Repairable" value="Repairable" <?php echo($row_status['repairable_status']=='Repairable')?'checked':'';?> />Repairable
	  <input type="radio" name="Repairable" id="Repairable" value="Non Repairable"<?php echo($row_status['repairable_status']=='Non Repairable')?'checked':'';?>>Non Repairable
	  <input type="radio" name="Repairable" id="Repairable" value="Abondoned"<?php echo($row_status['repairable_status']=='Abondoned')?'checked':'';?>>Abandoned	      </td>
  </tr>
	   <tr>
      <td>&nbsp;Remarks</td>
      <td>&nbsp;<input type="text" name="remarks" id="remarks" value="<?php echo $row_status['remark'];?>"/>	  </td>
      </tr>
	  </table>
	  </div>	  </td>
	  </tr>
	 
	  <tr>
	    <td colspan="2" align="center"><input type="submit" value="EDIT RECORD" name="submit" style="font-size: 8pt; font-family: Verdana; border-style: solid; border-width: 1px; font-weight:bold; background:#666666; color:#FFFFFF; width:140px; height:30px" onClick="view_validate()"></td>
  </tr>
  </table>
  </form>
</div>
</body>